package com.gxpt.app.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.gxpt.app.BaseFragment;
import com.gxpt.app.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by dufeng on 2017/9/8.
 */

@ContentView(R.layout.fragment_home_bak2)
public class Fragment_home_bak extends BaseFragment {



    Context context;

    @ViewInject(R.id.submenu0)
    LinearLayout submenu0;

    @ViewInject(R.id.submenu1)
    LinearLayout submenu1;

    @ViewInject(R.id.submenu2)
    LinearLayout submenu2;


    @ViewInject(R.id.line0)
    LinearLayout line0;

    @ViewInject(R.id.line1)
    LinearLayout line1;

    @ViewInject(R.id.line2)
    LinearLayout line2;

    int index = 0 ;//menu


    @Override
    public void onAttach(Context context) {
        this.context = context;
        super.onAttach(context);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        initData();
        return  x.view().inject(this, inflater, container);
    }

    private void initData(){

    }

    private void changeMenuView(){
        switch (index){
            case 0:
                line0.setBackgroundColor(getResources().getColor(R.color.red));
                line1.setBackgroundColor(getResources().getColor(R.color.white));
                line2.setBackgroundColor(getResources().getColor(R.color.white));
                break;
            case 1:
                line0.setBackgroundColor(getResources().getColor(R.color.white));
                line1.setBackgroundColor(getResources().getColor(R.color.red));
                line2.setBackgroundColor(getResources().getColor(R.color.white));
                break;
            case 2:
                line0.setBackgroundColor(getResources().getColor(R.color.white));
                line1.setBackgroundColor(getResources().getColor(R.color.white));
                line2.setBackgroundColor(getResources().getColor(R.color.red));
                break;
        }
    }



    @Event(value={R.id.submenu0,R.id.submenu1,R.id.submenu2})
    private void getEvent(View view){
        switch(view.getId()){

            case R.id.submenu0:
                if(index != 0){
                    index = 0 ;
                    changeMenuView();
                }


                break;
            case R.id.submenu1:
                if(index != 1){
                    index = 1 ;
                    changeMenuView();
                }


                break;
            case R.id.submenu2:
                if(index != 2){
                    index = 2 ;
                    changeMenuView();
                }


                break;

        }
    }

}
